<%
/**
 *  edit 职工编辑
 * 
 * @author  李荣华
 * @version v1.0
 * @date    2017-12-18
 * @since   JSP 2.3.1
 */
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="at" uri="http://www.jketing.com/at"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>职工编辑</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta content="no-cache" http-equiv="Pragma"/>
	<meta content="no-cache" http-equiv="Cache-Control"/>
	<meta content="0" http-equiv="Expires"/>
	<meta name="GENERATOR" content="MSHTML 8.00.6001.18854"/>
	<link rel="stylesheet" type="text/css" href="<at:url css="edit.css"/>" />
	<link rel="stylesheet" type="text/css" href="<at:url css="banner_button.css"/>" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/scripts/Common/validation-engine-2.2/css/validationEngine.jquery.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/scripts/Common/validation-engine-2.2/css/template.css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/jquery.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/common.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/select.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/common/My97DatePicker/WdatePicker.js"></script>	
	<script type="text/javascript" 
	src="${pageContext.request.contextPath}/scripts/Common/validation-engine-2.2/languages/jquery.validationEngine-cn.js" 
	charset="utf-8"></script>
	<script type="text/javascript" 
	src="${pageContext.request.contextPath}/scripts/Common/validation-engine-2.2/jquery.validationEngine.js" 
	charset="utf-8"></script>
	<script type="text/javascript" src="<at:url js="edit.js"/>"></script>
	<script type="text/javascript">
		/**
		  *提交
		  */
		function submit() {
			/* if($("#webForm").validationEngine('validate')){//表单验证
				document.getElementById("webForm").submit();		
			} */
			document.getElementById("webForm").submit();		
		}
	
		/**
		 * 返回列表操作 
		 */
		function ret() {
			if (window.confirm('数据没保存，你确定要返回列表吗？')) {
				setTimeout(
				function() {
					//js重定向到列表
					window.location.href = "${pageContext.request.contextPath}/employee/list";
				}, 0);
			}
		}
		
		/**
		 * 重置操作 
		 */
		function reset() {
			document.getElementById("webForm").reset();
		}
		
		/**
		 * 根据身份证号码获取性别、生日
		 * @author 张彬
		 * @Date 2011-12-31
		 */
		function getInfo(){
			var birthday;
			var cardNum = document.getElementById("cardId").value; 
			var sexSelect = document.getElementById("sex");
			switch(cardNum.length){
				case 15:
					if(!$("#webForm").validationEngine('validateField', "#cardId")){
						if(cardNum.substr(13,1)%2 == "0")
							sexSelect.options[2].selected=true;
						else
							sexSelect.options[1].selected=true;
						birthday = "19" + cardNum.substr(6,2) + "-" + cardNum.substr(8,2) + "-" + cardNum.substr(10,2);
						document.getElementById("birthday").value = birthday;
					}else
						document.getElementById("birthday").value = "";
					break;
				case 18:
					if(!$("#webForm").validationEngine('validateField', "#cardId")){
						if(cardNum.substr(16,1)%2 == "0")
							sexSelect.options[2].selected=true;
						else
							sexSelect.options[1].selected=true;
						birthday = cardNum.substr(6,4) + "-" + cardNum.substr(10,2) + "-" + cardNum.substr(12,2);
						document.getElementById("birthday").value = birthday;
					}else
						document.getElementById("birthday").value = "";
					break;
			}
		}
		
		/**
		 * 找开机构多选对话框
		 * @author 李荣华
		 */
		function organMultiSelect(ids,names){
			var myObject = new Object();
			myObject.breakcall = multiBreakcall;
			myObject.idValues = document.getElementById(ids).value;
			myObject.nameValues = document.getElementById(names).value;
			myObject.ids = ids;
			myObject.names = names;
		    window.showModalDialog('${pageContext.request.contextPath}/organ/multiSelect',
		    myObject, 'dialogWidth: 482px; dialogHeight: 442px; edge: Raised; center: Yes; help: Yes; resizable: No; scroll:No; status: No;');	
		    
		}
		
		/**
		 * validation-engine 表单验证
		 */
		jQuery(document).ready(function(){
               /* jQuery("#webForm").validationEngine({
               	validationEventTriggers:"keyup blur",  //触发的事件  validationEventTriggers:"keyup blur",   
               	inlineValidation: true,//是否即时验证，false为提交表单时验证,默认true   
               	success :  false,//为true时即使有不符合的也提交表单,false表示只有全部通过验证了才能提交表单,默认false   
               	promptPosition: "topRight"//提示所在的位置，topLeft, topRight, bottomLeft,  centerRight, bottomRight   
               	//failure : function() { alert("验证失败，请检查。");  }//验证失败时调用的函数   
               	//success : function() { callSuccessFunction() },//验证通过时调用的函数     
               }); */
               	<c:choose>
					<c:when test="${entity.id!=null}">
						var ids = "";
						var names = "";
						<c:forEach items="${organs}" var="item">
			               ids = ids + "${item.id},";
			               names = names + "${item.name},";
					   </c:forEach>
					   document.getElementById('ids').value = ids.substring(0,ids.length-1);
		               document.getElementById('names').value = names.substring(0,names.length-1);
				   	</c:when> 
				   	<c:otherwise>
				   		document.getElementById('ids').value = '${ids}';
		                document.getElementById('names').value = '${names}';
				   	</c:otherwise>  
				</c:choose>
		});	
	</script>
	<c:set value="${pageContext.request.contextPath}/employee" var="url"></c:set>
	<c:if test="${entity.id != null }">
		<c:set value="${pageContext.request.contextPath}/employee/${entity.id}" var="url"></c:set>
	</c:if>
</head>
<body>		
	<form:form action="${url}" method="POST" enctype="multipart/form-data"
		modelAttribute="entity" class="form-style" id="webForm" name="webForm">
		<c:if test="${entity.id!=null}">
			<form:hidden path="id"/>
			<input type="hidden" name="_method" value="PUT"/>
		</c:if>
		<input type="hidden" name="page" value="${page}"/>	
		<input type="hidden" name="order" value="${order}" />
		<!-- 按钮行 -->
		<div class="edit_top_f">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="4" height="24" id="kj2z03"></td>
					<td class="biao3_xia">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td height="24" class="biao4_zhong">
									<div id="nav_01">
										<ul>
											<li><a href="#" onclick="ret();">返回</a></li>
											<li><a href="#" onclick="submit();">提交</a></li>
										</ul>
									</div>
								</td>
							</tr>
						</table>
					</td>
					<td width="4" height="24" id="kj2y03"></td>
				</tr>
			</table>
		</div>
		<div class="edit_main_f">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<table width="100%" border="0" cellspacing="0" cellpadding="0"
							rules="groups">
							<tr>
								<td width="20%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td align="right" valign="middle" class="font_1">
												<nobr>姓名</nobr>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="30%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td align="left">
												<form:input path="name" class="validate[required]" id="objectName" style="width:90%"/>
												<font color="red">*</font>	
											</td>																		
										</tr>
									</table>
								</td>
								<td width="50%" height="100%" class="biantiao_you" rowspan="9" colspan="2">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="100%" align="center" valign="middle" class="font_1" >
												<c:choose>
													<c:when test="${entity.id!=null}">
														<img src="${pageContext.request.contextPath}/employee/getImage/${entity.id}"  width="105px" height="129px" alt="机构照片" />
												   	</c:when> 
												   	<c:otherwise>
												   		<img src="${pageContext.request.contextPath}/res/image/person_default.jpg" width="105px" height="129px" alt="机构照片" />
												   	</c:otherwise>  
												</c:choose>
											</td>																				
										</tr>
									</table>
								</td>													
							</tr>
																											
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="2"></td>																	
							</tr>																
							<tr>																
								 <td width="20%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" valign="middle" class="font_1">
												<nobr>性别</nobr>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="30%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="91%" align="left">
												<select class="select" id="sexId" name="sex.id" style="width:90.5%">
													<option value="">请选择</option>
													<c:forEach items="${sex}" var="item">
														<c:choose>
															<c:when test="${entity.sex.id==item.id}">
														   		<option value="${item.id}" selected='selected'>${item.name}</option>
														   	</c:when> 
														   	<c:otherwise>
														   		<option value="${item.id}">${item.name}</option>
														   	</c:otherwise>  
														</c:choose>
													</c:forEach>
												</select>
												<font color="red">*</font>												
											</td>																																							
										</tr>
									</table>
								</td>																									
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="2"></td>																	
							</tr>																
							<tr>																
								 <td width="20%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" valign="middle" class="font_1">
												<nobr>民族</nobr>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="30%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="91%" align="left">
												<select class="select" id="nationId" name="nation.id" style="width:90.5%">
													<option value="">请选择</option>
													<c:forEach items="${nation}" var="item">
														<c:choose>
															<c:when test="${entity.nation.id==item.id}">
														   		<option value="${item.id}" selected='selected'>${item.name}</option>
														   	</c:when> 
														   	<c:otherwise>
														   		<option value="${item.id}">${item.name}</option>
														   	</c:otherwise>  
														</c:choose>
													</c:forEach>
												</select>
												<font color="red">*</font>												
											</td>																																							
										</tr>
									</table>
								</td>																									
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="2"></td>																	
							</tr>																
							<tr>																
								 <td width="20%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" valign="middle" class="font_1">
												<nobr>出生日期</nobr>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="30%" height="100%" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td align="left">
												<form:input path="birthday" 
												class="validate[required]" 
												id="objectName" 
												readonly="readonly"
												onfocus="WdatePicker({isShowWeek:true});"
												style="width:90%"/>
												<font color="red">*</font>											
											</td>																																							
										</tr>
									</table>
								</td>																									
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="2"></td>																	
							</tr>	
							<tr>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>证件类型</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<select class="select" id="cardTypeId" name="cardType.id" style="width:90.5%">
													<c:forEach items="${cardType}" var="item">
														<c:choose>
															<c:when test="${entity.cardType.id==item.id}">
														   		<option value="${item.id}" selected='selected'>${item.name}</option>
														   	</c:when> 
														   	<c:otherwise>
														   		<option value="${item.id}">${item.name}</option>
														   	</c:otherwise>  
														</c:choose>
													</c:forEach>
												</select>
												<font color="red">*</font>
											</td>																				
										</tr>
									</table>
								</td>
							</tr>	
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="4"></td>																	
							</tr>	
							<tr>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>证件号码</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td align="left">
												<form:input path="cardId" class="validate[required]" id="objectName" style="width:90%"/>
												<font color="red">*</font>	
											</td>																				
										</tr>
									</table>
								</td>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>个人照片</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="40">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<input type="file" name="file" size="90%" style="width:90%"/>
											</td>																				
										</tr>
									</table>
								</td>
							</tr>	
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="4"></td>																	
							</tr>	
							<tr>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" class="font_1">
												<nobr>所属部门</nobr>
											</td>																				
										</tr>
									</table>																		
								</td>
								<td width="30%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<input class="validate[required]"
														type="hidden" id="ids" name="ids"
														value="" /> 
													<input id="names"
														name="names"
														onclick="organMultiSelect('ids','names');"
														value="" alt="所属部门"
														readonly="readonly" style="width:90%" /> 
														<font color="red">*</font>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>毕业院校</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="40">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<form:input path="school" class="validate[required]" id="objectName" style="width:90%"/>
												<font color="red">*</font>	
											</td>																				
										</tr>
									</table>
								</td>
							</tr>	
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="4"></td>																	
							</tr>	
							<tr>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" class="font_1">
												<nobr>学历</nobr>
											</td>																				
										</tr>
									</table>																		
								</td>
								<td width="30%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td align="left">
												<select class="select" name="educationalBackground.id" style="width:90.5%">
													<option value="">请选择</option>
													<c:forEach items="${educationalBackground}" var="item">
														<c:choose>
															<c:when test="${entity.educationalBackground.id==item.id}">
														   		<option value="${item.id}" selected='selected'>${item.name}</option>
														   	</c:when> 
														   	<c:otherwise>
														   		<option value="${item.id}">${item.name}</option>
														   	</c:otherwise>  
														</c:choose>
													</c:forEach>
												</select>
												<font color="red">*</font>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>专业</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="40">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<form:input path="speciality" class="validate[required]" id="objectName" style="width:90%"/>
												<font color="red">*</font>	
											</td>																				
										</tr>
									</table>
								</td>
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td height="1" class="biaotiao_xia" colspan="4"></td>																	
							</tr>	
							<tr>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>
											<td width="25%" align="right" class="font_1">
												<nobr>职称</nobr>
											</td>																				
										</tr>
									</table>																		
								</td>
								<td width="30%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td align="left">
												<select class="select" id="qualificationId" name="qualification.id" style="width:90.5%">
													<option value="">请选择</option>
													<c:forEach items="${qualification}" var="item">
														<c:choose>
															<c:when test="${entity.qualification.id==item.id}">
														   		<option value="${item.id}" selected='selected'>${item.name}</option>
														   	</c:when> 
														   	<c:otherwise>
														   		<option value="${item.id}">${item.name}</option>
														   	</c:otherwise>  
														</c:choose>
													</c:forEach>
												</select>
												<font color="red">*</font>
											</td>																				
										</tr>
									</table>
								</td>
								<td width="20%" height="40" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>职务</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="40">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<select class="select" id="dutyId" name="duty.id" style="width:90.5%">
													<option value="">请选择</option>
													<c:forEach items="${duty}" var="item">
														<c:choose>
															<c:when test="${entity.duty.id==item.id}">
														   		<option value="${item.id}" selected='selected'>${item.name}</option>
														   	</c:when> 
														   	<c:otherwise>
														   		<option value="${item.id}">${item.name}</option>
														   	</c:otherwise>  
														</c:choose>
													</c:forEach>
												</select>
												<font color="red">*</font>
											</td>																				
										</tr>
									</table>
								</td>
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td colspan="4">
									<div style="height: 1;" class="biaotiao_xia"></div>
								</td>
							</tr>
							<tr>	
								<td width="20%" height="30" class="biantiao_you">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
											<tr>
												<td width="25%" align="right" class="font_1">
													<nobr>备注</nobr>
												</td>																				
											</tr>
										</table>																		
								</td>
								<td width="30%" height="30" colspan="4">
									<table width="100%" border="0" cellspacing="5" cellpadding="5">
										<tr>																				
											<td width="100%" align="left">
												<form:textarea path="remark" rows="8" cols="79" style="width:96.5%"/>
											</td>
										</tr>
									</table>
								</td>	
							</tr>
							<!-- 行分割线 -->
							<tr>
								<td colspan="4">
									<div style="height: 1;" class="biaotiao_xia"></div>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
	</form:form>
</body>
</html>
